<?php
/*
 * @Author: lokei
 * @Date: 2022-11-09 15:27:20
 * @LastEditors: lokei
 * @LastEditTime: 2022-11-09 15:50:00
 * @Description: 
 */
namespace App\Http\Controllers\Schedule;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Schedule\Time\ScheduleTimeModel;
use Illuminate\Http\Request;

class SlotController extends Controller {
    public function statusOfMe(Request $request) {
        $user = app('auth')->user();
        $items = ScheduleTimeModel::where('uid', '=', $user->uid)->where('day', '=', $request->input('day'))->where('slot_id', '=', $request->input('slot_id'))->get();
        $res = ResultTool::success();
        $res['data']['items'] = $items;
        return $res;
    }

    public function add(Request $request) {
        $user = app('auth')->user();
        $schedule = new ScheduleTimeModel();
        $schedule->uid = $user->uid;
        $schedule->day = $request->input('day');
        $schedule->slot_id = $request->input('slot_id');
        $schedule->mode = $request->input('mode');
        $schedule->save();
        return ResultTool::success();
    }

    public function delete(Request $request) {
        ScheduleTimeModel::where('id', '=', $request->input('id'))->delete();
        return ResultTool::success();
    }
}